package com.mayuhao.studentmanage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mayuhao.studentmanage.entity.CssStuChoose;
import com.mayuhao.studentmanage.entity.CssStudent;
import com.mayuhao.studentmanage.entity.CssStudentVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 马宇豪
 * @since 2022-10-26
 */
public interface CssStudentMapper extends BaseMapper<CssStudent> {

    Page<CssStudentVO> findPage(Page<CssStudentVO> studentVOPage, @Param("searchId") String searchId, @Param("searchName") String searchName);

    Page<CssStudentVO> findAllPage(Page<CssStudentVO> cssStudentPage, @Param("searchId") String searchId, @Param("searchName") String searchName);

    @Select("SELECT css_choose_course.student_id,css_choose_course.course_id FROM css_choose_course")
    List<CssStuChoose> selectStuChoose();

    @Insert("insert into css_choose_course values (#{studentId},#{courseId},null)")
    boolean saveStuChoose(@Param("studentId") String studentId, @Param("courseId") String courseId);

    @Delete("delete from css_choose_course where  css_choose_course.course_id=#{id}")
    boolean removeId(Integer id);

    @Update("UPDATE css_choose_course SET css_choose_course.course_score =#{courseScore} WHERE css_choose_course.student_id =#{studentId} AND css_choose_course.course_id =#{courseId}")
    boolean updateStuChoose(@Param("studentId") String studentId, @Param("courseId") String courseId, @Param("courseScore") String courseScore);
}
